import '../../../../hj_model/splash/ads_model.dart';
import 'AiChangeFaceVideoMod.dart';

//ai脱衣模版
class AiModList {
  AiModList({
    this.aiUndressMod,
    this.aiChangeFaceVideoMod,
    this.aiChangeFaceMod,
  });

  AiModList.fromJson(dynamic json) {
    if (json['aiUndressMod'] != null) {
      aiUndressMod = [];
      json['aiUndressMod'].forEach((v) {
        aiUndressMod?.add(AdsInfoModel.fromJson(v));
      });
    }
    if (json['aiChangeFaceVideoMod'] != null) {
      aiChangeFaceVideoMod = [];
      json['aiChangeFaceVideoMod'].forEach((v) {
        aiChangeFaceVideoMod?.add(AiChangeFaceVideoMod.fromJson(v));
      });
    }
    if (json['aiChangeFaceMod'] != null) {
      aiChangeFaceMod = [];
      json['aiChangeFaceMod'].forEach((v) {
        aiChangeFaceMod?.add(AiChangeFaceVideoMod.fromJson(v));
      });
    }
  }

  /// 脱衣模版
  List<AdsInfoModel>? aiUndressMod;

  /// 视频换脸模版
  List<AiChangeFaceVideoMod>? aiChangeFaceVideoMod;

  /// 图片换脸模版
  List<AiChangeFaceVideoMod>? aiChangeFaceMod;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    if (aiUndressMod != null) {
      map['aiUndressMod'] = aiUndressMod?.map((v) => v.toJson()).toList();
    }
    if (aiChangeFaceVideoMod != null) {
      map['aiChangeFaceVideoMod'] = aiChangeFaceVideoMod?.map((v) => v.toJson()).toList();
    }
    if (aiChangeFaceMod != null) {
      map['aiChangeFaceMod'] = aiChangeFaceMod?.map((v) => v.toJson()).toList();
    }
    return map;
  }
}

//ai换脸模版
class AiChangeModList {
  String? categoryId;
  List<AICategoryMod>? categoryList;
  List<TemplateModel>? templateList;

  AiChangeModList({this.categoryId, this.categoryList, this.templateList});

  AiChangeModList.fromJson(Map<String, dynamic> json) {
    categoryId = json['categoryId'];
    if (json['categoryList'] != null) {
      categoryList = <AICategoryMod>[];
      json['categoryList'].forEach((v) {
        categoryList!.add(new AICategoryMod.fromJson(v));
      });
    }
    if (json['templateList'] != null) {
      templateList = <TemplateModel>[];
      json['templateList'].forEach((v) {
        templateList!.add(new TemplateModel.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['categoryId'] = this.categoryId;
    if (this.categoryList != null) {
      data['categoryList'] = this.categoryList!.map((v) => v.toJson()).toList();
    }
    if (this.templateList != null) {
      data['templateList'] = this.templateList!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class AICategoryMod {
  int? appId;
  String? createdAt;
  String? id;
  String? name;
  int? sortCode;
  int? status;
  List<String>? templateIds;
  int? type;
  String? updatedAt;

  AICategoryMod({
    this.appId,
    this.createdAt,
    this.id,
    this.name,
    this.sortCode,
    this.status,
    this.templateIds,
    this.type,
    this.updatedAt,
  });

  AICategoryMod.fromJson(Map<String, dynamic> json) {
    appId = json['appId'];
    createdAt = json['createdAt'];
    id = json['id'];
    name = json['name'];
    sortCode = json['sortCode'];
    status = json['status'];
    templateIds = json['templateIds'] != null ? json['templateIds'].cast<String>() : [];
    type = json['type'];
    updatedAt = json['updatedAt'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['appId'] = this.appId;
    data['createdAt'] = this.createdAt;
    data['id'] = this.id;
    data['name'] = this.name;
    data['sortCode'] = this.sortCode;
    data['status'] = this.status;
    data['templateIds'] = this.templateIds;
    data['type'] = this.type;
    data['updatedAt'] = this.updatedAt;
    return data;
  }
}

class TemplateModel {
  String? categoryId; //分类id
  int? coin; //价格(金币)
  String? cover; //封面
  String? createdAt; //创建时间
  String? id;
  int? moduleType; //换脸模版类型 0 图片 1 视频
  String? mp4Url; //视频mp4地址
  String? m3u8Url;
  String? title;
  int? usedCount; //模版使用次数
  int? vipCoin;

  int get timestamp {
    if (createdAt != null) {
      var date = DateTime.parse(createdAt!).toLocal();
      return date.millisecond;
    } else {
      return 0;
    }
  }

  TemplateModel(
      {this.categoryId,
      this.coin,
      this.cover,
      this.createdAt,
      this.id,
      this.moduleType,
      this.mp4Url,
      this.title,
      this.usedCount,
      this.vipCoin});

  TemplateModel.fromJson(Map<String, dynamic> json) {
    categoryId = json['categoryId'];
    coin = json['coin'];
    cover = json['cover'];
    createdAt = json['createdAt'];
    id = json['id'];
    m3u8Url = json['m3u8Url'];
    moduleType = json['moduleType'];
    mp4Url = json['mp4Url'];
    title = json['title'];
    usedCount = json['usedCount'];
    vipCoin = json['vipCoin'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['categoryId'] = this.categoryId;
    data['coin'] = this.coin;
    data['cover'] = this.cover;
    data['createdAt'] = this.createdAt;
    data['id'] = this.id;
    data['moduleType'] = this.moduleType;
    data['mp4Url'] = this.mp4Url;
    data['title'] = this.title;
    data['usedCount'] = this.usedCount;
    data['vipCoin'] = this.vipCoin;
    return data;
  }
}
